#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
string s;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		cin >> s;
		int ans1 = 0, ans2 = 0;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == '1') {
				sum = 0;
			}
			else {
				sum++;
			}
			ans1 = max(ans1, sum);
		}
		sum = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == '0') {
				sum = 0;
			}
			else {
				sum++;
			}
			ans2 = max(ans2, sum);
		}
		int ans = max(ans1, ans2);
		cout << ans << endl;
	}
	return 0;
}

